package asynctask

import (
	"scase.io/application-auto-scaling-service/pkg/db"
	"scase.io/application-auto-scaling-service/pkg/utils/logger"
)

// 所有任务失败时回退期望实例数，防止无限创建
func UpdateDesireNum(log *logger.FMLogger, groupId string, instanceNum int32) {
	// 重新获取group，防止中途desireNum有变化
	err := db.ScalingGroupTable().TxUpdateScalingGroupDesNumber(groupId, instanceNum)
	if err != nil {
		log.Error("update group [%s] desire number %d error:%+v", groupId, instanceNum)
		return
	}
}
